unit Unitmessage;

interface

uses Windows, SysUtils, Classes, Graphics, Forms, Controls, StdCtrls,
  Buttons, ExtCtrls, cxControls, cxLookAndFeels,
  cxContainer, cxEdit,cxLabel, cxGroupBox, cxGraphics, dxSkinsCore, cxLookAndFeelPainters,
  dxSkinsDefaultPainters, dxSkinOffice2010Blue, dxSkinWhiteprint;

type
  TmessageDlg = class(TForm)
    OKBtn: TButton;
    CancelBtn: TButton;
    cxGroupBox1: TcxGroupBox;
    cxLabel1: TcxLabel;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  messageDlg: TmessageDlg;
function  mydlg(s:string;showbutton:integer=0):Integer;
implementation

{$R *.dfm}

procedure TmessageDlg.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action:=cafree;
messageDlg:=nil;
end;
function  mydlg(s:string;showbutton:integer=0):Integer;
begin
messageDlg:=TmessageDlg.Create(Application);
messagedlg.cxLabel1.Caption:=s;
case showbutton of
1: //show cancel
begin
messageDlg.CancelBtn.Left:=(messageDlg.Width-messagedlg.CancelBtn.Width)div 2;
messageDlg.OKBtn.Visible:=False;

end;
2: // show ok button
begin
messageDlg.CancelBtn.Visible:=False;
messageDlg.OKBtn.Left:=(messageDlg.Width-messagedlg.OKBtn.Width)div 2 ;
end;
end;
messageDlg.BringToFront;
Result:=messageDlg.ShowModal();
end;

end.
